
modifier_fixed_armor_for_hero = class({})

local public = modifier_fixed_armor_for_hero

--------------------------------------------------------------------------------

function public:IsDebuff()
	return false
end

--------------------------------------------------------------------------------

function public:IsHidden()
	return true
end

--------------------------------------------------------------------------------

function public:IsPurgable()
	return false
end

--------------------------------------------------------------------------------

function public:DeclareFunctions()
	local funcs = {
		MODIFIER_EVENT_ON_ATTACK_LANDED,
	}
	return funcs
end

function public:GetAttackDamage( unit )
	local base = unit:GetAttackDamage()

	if unit:IsHero() then
		-- 主属性增加的伤害
		base = base + unit:GetBonusDamageFromPrimaryStat()

		local lifesteal = 0
		for i=0,5 do
			local item = unit:GetItemInSlot(i)
			if item then
				local lifesteal_percent = item:GetSpecialValueFor('lifesteal_percent') or 0
				if lifesteal_percent > 0 then
					lifesteal = lifesteal + lifesteal_percent
				end
			end
		end

		if lifesteal > 0 then
			unit:Heal(base*(lifesteal/100), nil)
		end
	end

	return base
end

function public:OnAttackLanded( keys )
	if IsServer() then
		-- if keys.attacker == self:GetCaster() and keys.target ~= self:GetCaster() then
		-- 	local attacker = keys.attacker
		-- 	local target = keys.target
		-- 	local damage = self:GetAttackDamage( attacker )

		-- 	ApplyDamage({
		-- 		attacker = attacker,
		-- 		victim = target,
		-- 		damage_type = DAMAGE_TYPE_PURE, 
		-- 		damage = damage,
		-- 	})
		-- end
		self:GetCaster():AddNewModifier( self:GetCaster(), nil, "modifier_fixed_armor", {duration=1} )
	end
end